package com.mgq.netty.c6;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

@Slf4j
public class TestJDKFuture {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> future = service.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                log.debug("执行计算");
                Thread.sleep(2000);
                return 50;
            }
        });
        //阻塞等待结果
        log.debug("阻塞等待结果");
        log.debug("结果是{}", future.get());
        service.shutdown();
    }
}
